package com.coderman.infosys.auth.infrast.gatawayimpl;

import com.coderman.infosys.auth.domain.bo.user.UserGroupBO;
import com.coderman.infosys.auth.domain.enums.BOIdentiferEnum;
import com.coderman.infosys.auth.domain.gataway.CacheServiceGataWay;
import com.coderman.infosys.auth.infrast.cache.SystemCache;
import com.coderman.infosys.auth.infrast.cache.UserAuthorityCache;
import com.coderman.infosys.auth.infrast.cache.UserRoleGroupCache;
import com.coderman.infosys.plat.auth.common.bo.BaseBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Description:
 * date: 2022/1/18
 *
 * @author shenshuai
 * @version 1.0.0
 * @since JDK 1.8
 */
@Service
public class CacheServiceGataWayImpl implements CacheServiceGataWay {

    @Autowired
    private UserAuthorityCache userAuthorityCache;

    @Autowired
    private SystemCache systemCache;

    @Autowired
    private UserRoleGroupCache userRoleGroupCache;


    @Override
    public void put(BOIdentiferEnum boIdentiferEnum, BaseBO bo) {
        if(BOIdentiferEnum.isUserGroup(boIdentiferEnum.getIdentifer())){
            userRoleGroupCache.putUserGroup((UserGroupBO) bo);
        }

    }

    @Override
    public BaseBO get(BOIdentiferEnum boIdentiferEnum, String identifer) {
        if(BOIdentiferEnum.isUserGroup(boIdentiferEnum.getIdentifer())){
            return userRoleGroupCache.getUserGroup(identifer);
        }
        return null;
    }

    @Override
    public List<BaseBO> getList(BOIdentiferEnum boIdentiferEnum) {
        return null;
    }

    @Override
    public Boolean remove(BOIdentiferEnum boIdentiferEnum, String identifer) {
        return null;
    }
}
